package edu.thu.studio.ormdesigner.outline.editpart;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import edu.thu.studio.ormdesigner.Activator;
import edu.thu.studio.ormdesigner.model.domain.Domain;
import edu.thu.studio.ormdesigner.model.domain.DomainSet;
import edu.thu.studio.ormdesigner.util.Properties;

public class DomainSetOutlineEditPart extends AbstractOutlineEditPart {
    
    /**
     * {@inheritDoc}
     */
    @Override
    @SuppressWarnings("rawtypes")
    protected List getModelChildren() {
        List<Domain> children = new ArrayList<Domain>();
        
        DomainSet domains = (DomainSet) this.getModel();
        
        for (Domain domain : domains.getObjectList()) {
            children.add(domain);
        }
        
        Collections.sort(children);
        return children;
    }
    
    /**
     * {@inheritDoc}
     */
    @Override
    protected void refreshOutlineVisuals() {
        this.setWidgetText(Properties.outline_label_domainset + " (" + this.getModelChildren().size() + ")");
        this.setWidgetImage(Activator.getImage(Properties.icon_domainset));
    }
    
}
